package com.cameronyule.echonest.suites.tests.artists
{
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	import org.flexunit.async.Async;

	public class UploadTest
	{		
		private var loader:URLLoader;		
		private var request:URLRequest;
		
		[Before(async)] 
		public function setUp():void
		{
			loader = new URLLoader();
			request = new URLRequest('http://www.cameronyule.com');
		}
		
		[After(async)] 
		public function tearDown():void
		{
			loader.close();
		}
		
		[Test(async)] 
		public function doSomethingAsynchronous():void
		{
			var passThroughData:Object = new Object();
			passThroughData.username = 'myuser1';
			passThroughData.password = 'a';
			
			Async.handleEvent(this, loader, Event.COMPLETE, loadCompleteHandler, 5000, passThroughData);
			
			loader.load(request);
		}
		
		private function loadCompleteHandler(event:Event, passThroughData:Object):void
		{
			trace('loadCompleteHandler: ' + event + ', ' + passThroughData.username);	
		}
	}
}